package insert;

import java.awt.Color;
import java.util.Random;

import model.MyVector;
import model.Particle;
import graphic.GamePanel;

public class RandomInserter extends Inserter{
	
	public RandomInserter(){
		super();
	}
	
	public RandomInserter(int period){
		super();
		setPeriod(period);
	}
	
	public void setRandomColor(Particle p){
		Random ran = new Random();
		int r = 0+ran.nextInt(255);
		int g = 0+ran.nextInt(255);
		int b = 0+ran.nextInt(255);
		p.setColor(new Color(r,g,b));
	}
	
	public void insert(GamePanel panel){
		Random ran = new Random();
		for(int i=0;i<20;i++){
			MyVector position = new MyVector(10+ran.nextInt(400),10+ran.nextInt(400));
			int vX = ran.nextInt(400);
			int vY = ran.nextInt(400);
			MyVector velocity = new MyVector(vX-200,vY-200);
			MyVector acceleration = new MyVector(0,80);
			int life = ran.nextInt(400);
			Particle p = new Particle(5);
			p.setPosition(position);
			p.setVelocity(velocity);
			p.setAcceleration(acceleration);
			p.setLife(life);
			setRandomColor(p);
			
			panel.addParticle(p);
		}
	}
}
